package com.thread.threadfirst.javaBase.java8;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.util.Date;

public class LocalDateTimeTest {

    public static void main(String[] args) {
        LocalDateTime current=LocalDateTime.now();
        System.out.println("当前时间: " + current);

        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:sss");
        System.out.println("sdf "+sdf.format(new Date()));

        System.out.println("day "+ current.toLocalDate());
        System.out.println("月 "+ current.getMonth() +" 日 "+current.getDayOfMonth() +" 秒 "+ current.getSecond());

        LocalDateTime localDateTime = current.withDayOfMonth(11).withMonth(11).withYear(2035);
        System.out.println(" future "+localDateTime);

        // 11 NOVEMBER 2035
        LocalDate date = LocalDate.of(2035, Month.NOVEMBER, 11);
        System.out.println("date1 "+date);

        // 23 小时 15 分钟
        LocalTime time=LocalTime.of(23,15);
        System.out.println("time1 "+time);

        // 解析字符串
        LocalTime date5 = LocalTime.parse("20:15:30");
        System.out.println("date5: " + date5);
    }
}
